Skip to content

Conversation

glady
Copy link

@glady glady commented Sep 12, 2025

Q A
Bug fix? no
New feature? no
Docs? no
Issues Fix #527
License MIT
  • Introduced a separate output processor, that accepts a result handler and gives the result of the Output data container to this handler.
  • removed dependency to symfony/ai-agent from composer file within platform subtree
  • added deptrac check

- Introduced a separate output processor, that accepts a result handler and gives the result of the Output data container to this handler.
- removed dependency to symfony/ai-agent from composer file within platform subtree
- added deptrac check
@carsonbot carsonbot changed the title Rewrite output processors from Agent side used by Platform Rewrite output processors from Agent side used by Platform Sep 12, 2025
@chr-hertel chr-hertel added the Hackathon 2025 This issue or pull request was part of the Symfony AI Hackathon 2025 label Sep 13, 2025
@chr-hertel
Copy link
Member

chr-hertel commented Sep 13, 2025

Thanks @glady for that proposal! The downside of introducing the new extension point ResultHandlerInterface like that is with standalone usage of the Platform component. So deptrac is great proof for having a proper decoupling, but imagine someone is not using the Agent component and wants to leverage the TokenUsageResultHandler as well - of course that's possible but only with their own glue code sticking the Platform's classes together.

An event-based solution didn't fly or was too much of hustle?

Edit:Maybe this could sit on top of #575?

@glady
Copy link
Author

glady commented Sep 13, 2025

@chr-hertel The event based solution had some more things to think about, I didn't want to introduce an additional dependency without thinking about more proper events. Not everyone is interested in using that, so he will need to write some glue code (like we also need with the agent usage and the processors) in order to "activate" it, so he will at least need to add a subscriber that still would call the result handler (so this class or something similar would be needed anyway). Thats why I decided to build an result output processor entry point like its used in the examples (and in the bundle as well).

My opinion: to introduce an event dispatcher with proper events (for more events than just result) is another (bigger) scope I didn't want to touch yesterday.

@chr-hertel
Copy link
Member

to introduce an event dispatcher with proper events (for more events than just result) is another (bigger) scope I didn't want to touch yesterday.

fair enough - and i agree that we could try to keep the event dispatcher dependency optional

other than that we could have input/output extension points instead of events, similar to the agent - to skip the event-dispatcher dependency - cc @OskarStark @RamyHakam any opinion on event dispatcher vs explicit lib-specific extension point?

@OskarStark
Copy link
Contributor

The explanation sounds valid so let's try the extension points 🙌

@chr-hertel
Copy link
Member

alright, just lost my mind, was close to proposing OutputConverterInterface and realized that we have a ResultConverterInterface already 😂

So we have already an explicit extension point - but we can't directly use it with additional result converters for the tokens - now i wonder if we can extend the current ones without bringing even more concerns to the existing implementations.

@glady
Copy link
Author

glady commented Sep 13, 2025

@chr-hertel yes, I recognized this result converter interface too, but it is "first match" and just handles the model-based conversions (raw result -> result), which is something that should work out-of-the-box not like the optional token usage. Maybe the token usage can be an option to be put to those converters (as option given to Platform::invoke call). In this case my classes would be obsolete, indeed.

@OskarStark OskarStark added Platform Issues & PRs about the AI Platform component Agent Issues & PRs about the AI Agent component AI Bundle Issues & PRs about the AI integration bundle labels Sep 15, 2025
@carsonbot carsonbot changed the title Rewrite output processors from Agent side used by Platform [AI Bundle][Agent][Platform] Rewrite output processors from Agent side used by Platform Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Agent Issues & PRs about the AI Agent component AI Bundle Issues & PRs about the AI integration bundle Hackathon 2025 This issue or pull request was part of the Symfony AI Hackathon 2025 Platform Issues & PRs about the AI Platform component Status: Needs Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Platform] Decouple Token Processors from Agent component
4 participants